package top.tenebrous.yzl.chat.service.impl.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.tenebrous.yzl.chat.domain.system.SysMenu;
import top.tenebrous.yzl.chat.mapper.system.SysMenuMapper;
import top.tenebrous.yzl.chat.service.system.ISysMenuService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @autor: tylong
 * @date: 2021/7/22 15:20
 * @company: CTS
 * @version: 1.0
 */
@Slf4j
@Service("sysMenuService")
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {

    @Resource
    private SysMenuMapper sysMenuMapper;

    /**
     * 通过用户的id 查询用户的菜单数据
     *
     * @param userId
     * @return
     */
    @Override
    public List<SysMenu> getMenusByUserId(Long userId,Integer bizType) {
        // 1 如果该用户是超级管理员->>拥有所有的菜单
        if (null != userId && userId == 1) {
            return list(new LambdaQueryWrapper<SysMenu>()
                    .eq(SysMenu::getIsVisible,1)
                    .eq(SysMenu::getBizType,1)
            ); // 根据条件查询所有
        }
        // 2 如果该用户不是超级管理员->>查询角色->查询菜单
        return sysMenuMapper.selectMenusByUserId(userId,bizType);
    }


}







